package com.jrx.anytxn.accounting.job.glinterfaceInvestor.step;

import com.jrx.anytxn.accounting.mapper.ext.ExtTlGlInterfaceInvestorInfoExcpMapper;
import com.jrx.anytxn.accounting.service.IVoucherInfoService;
import com.jrx.anytxn.param.entity.PrOrganizationTable;
import com.jrx.anytxn.param.service.system.IOrganizationTableService;
import com.jrx.anytxn.transaction.constant.TransBizConstant;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class GlInterfaceInvestorListener implements JobExecutionListener {

    @Autowired
    private IOrganizationTableService organizationTableService;
    @Autowired
    private IVoucherInfoService voucherInfoService;
    @Resource
    private ExtTlGlInterfaceInvestorInfoExcpMapper extTlGlInterfaceInvestorInfoExcpMapper;


    @Override
    public void beforeJob(JobExecution jobExecution) {
           PrOrganizationTable org = organizationTableService.findByOrgIdForBatch(TransBizConstant.DEFAULT_ORG_ID);
        Date businessDate = org.getToday();
        //需要区分联合贷和非联合贷来删除
        voucherInfoService.deleteByDateAndInvestorId(businessDate,"");
        extTlGlInterfaceInvestorInfoExcpMapper.deleteByDate(businessDate);
}

    @Override
    public void afterJob(JobExecution jobExecution) {

    }
}
